//#include "lvgl.h"
#include "lv_persian_ime.h"

#define LV_KB_BTN(width) LV_BTNMATRIX_CTRL_POPOVER | width

static const char * const default_kb_map_ko[] = {"1#", "پ", "ب", "ج", "د", "ف", "ق", "و", "ل", "م", "ن", LV_SYMBOL_BACKSPACE, "\n",
                                                 "ABC", "گ", "ه", "ی", "ر", "ز", "س", "ش", "ت", "خ", "ع", LV_SYMBOL_NEW_LINE, "\n",
                                                 "آ", "إ", "ا", "و", "ط", "ظ", "ص", "د", "ذ", "ر", ".", ",", ":", "\n",
                                                 LV_SYMBOL_KEYBOARD, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_KEYPAD_TYPE_PERSIAN,"\n",
                                                 LV_EARTH_ICON, ""
                                                };


static const lv_btnmatrix_ctrl_t default_kb_ctrl_ko_map[] = {
    LV_KEYBOARD_CTRL_BTN_FLAGS | 5, LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_BTNMATRIX_CTRL_CHECKED | 7,
    LV_KEYBOARD_CTRL_BTN_FLAGS | 6, LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BTNMATRIX_CTRL_CHECKED | 7,
    LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1),
    LV_KEYBOARD_CTRL_BTN_FLAGS | 2, LV_BTNMATRIX_CTRL_CHECKED | 2, 6, LV_BTNMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2,
    LV_KEYBOARD_CTRL_BTN_FLAGS | 2
};

LV_FONT_DECLARE(lv_arabic_font);

// 布局切换回调
static void kb_event_cb(lv_event_t *e) {
   
    lv_obj_t *kb = lv_event_get_user_data(e);
    const char *btn_txt = lv_btnmatrix_get_btn_text(kb, lv_btnmatrix_get_selected_btn(kb));

}
int init_persian_keypad_map(lv_obj_t *kb)
{
    if(!kb)
    {
        return -1;
    }
    // 初始化键盘布局
    lv_keyboard_set_map(kb, LV_KEYPAD_MODE_PERSIAN, default_kb_map_ko,default_kb_ctrl_ko_map);
    //设置键盘字体
    lv_obj_set_style_text_font(kb, &lv_arabic_font, 0); 
    // 绑定事件
    //lv_obj_add_event_cb(kb, kb_event_cb, LV_EVENT_CLICKED, kb);
    

    return 0;
}